<?php

include_once 'ConditionStatement.php';
include_once 'CaseStatementCollection.php';

/**
 * Represents a switch statement
 * 
 * @package UC_PHPCodeModel
 * @author Uros Calakovic
 * @example ../Examples/SwitchStatementExample.php 
 */

class SwitchStatement extends ConditionStatement
{
    /**
     * The SwitchStatement constructor
     * 
     * @param Expression $Condition The switch statement condition
     * @param CaseStatementCollection $CaseStatements The case statements
     */
    
    public function __construct(
        Expression $Condition, CaseStatementCollection $CaseStatements = null)
    {
        parent::__construct();
        $this->set_Condition($Condition);
        
        $CaseStatements == null ?
            $this->CaseStatements = new CaseStatementCollection() : 
            $this->set_CaseStatements($CaseStatements);
    }
    
    /**
     * Used for making private / protected variables 
     * accessible from outside the class.
     * 
     * @param string $name Name of the field to be accessed
     * @param mixed $value The value the field should be set to, usually a collection.
     * @see CodeObject::__set()
     */
    
    public function __set($name, $value)
    {
        parent::__set($name, $value);
        
        if ($name == 'CaseStatements')
        {
            $this->set_CaseStatements($value);
        }
    }
    
    /**
     * Used for making private / protected variables 
     * accessible from outside the class.
     * 
     * @param string $name Name of the field to be accessed
     * @return mixed The field that $name specified, usually a collection
     * @see CodeObject::__get()
     */
    
    public function __get($name)
    {
        $ret = parent::__get($name);
        
        if($ret != null)
        {
            return $ret;
        }
        
        if($name == 'CaseStatements')
        {
            return $this->get_CaseStatements();
        }
    }
    
    /**
     * The $CaseStatements getter method
     * @return CaseStatementCollection 
     */
    
    public function get_CaseStatements()
    {
        return $this->CaseStatements;
    }
    
    /**
     * The $CaseStatements setter method
     * @param CaseStatementCollection $CaseStatements 
     * 
     * @assert (123) throws PHPUnit_Framework_Error
     * @assert ('name') throws PHPUnit_Framework_Error
     * @assert (new stdClass()) throws PHPUnit_Framework_Error
     */

    public function set_CaseStatements(CaseStatementCollection $CaseStatements)
    {
        $this->CaseStatements = $CaseStatements;
    }

    /**
     * The case statements
     * @var CaseStatementCollection 
     */
    
    private $CaseStatements;
}

?>
